#pragma once

#include "DictionaryTree.h"
//#include <windows.h>
#include <math.h>
#include <vector>
#include <algorithm>

#define COLS 13
#define ROWS 9

struct pos {
	char letter;
	int x,y;
};

class Word
{
public:
	int points;
	int length;
	struct pos word[30];
};


class Grid
{
public:
	Grid();
	Grid(Grid * old);
	~Grid(void);
	void GetGrid(char * inputgrid);
	void PrintGrid();
	void FallGrid();
	//int GetPoints(char letter);
	bool IsValid(int x, int y);
	void FindWords();
	void ApplyWord(struct pos * word, int length);
	
	int numletters;
	int Letters();
	int GetTail();
	//int letcount[26];
	double Shape();
	double Ratio();
	//float Gradient();
	int words,mostvalue,wordlen;
	struct pos word[30];
	void (*pCallBack)(Grid * grid);
	
	char grid[COLS][ROWS];

	std::vector<Word*> wordlist;

	struct pos current[30];
	int length;
	bool timed;

	Grid * next;

private:
	
	void ScanLetter(DictionaryNode * parse, int x, int y);
	void ScanWord(DictionaryNode * parse, int x, int y);
	void FindWord(int x, int y);
	
};



typedef void (*CallBack)(Grid * grid);
